<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <title>05_案例练习-数组去重2</title>
    </head>
    <body>
        <script>
            var arr = [1,0,2,0,3,0,4,0,5,0,0,5,0,4,0,3,0,2,0,1,0];

            var new_arr = [];

            for(var i = 0; i < arr.length; i++){

                var flag = true;

                for(var j = 0; j < new_arr.length; j++){
                    if(arr[i] == new_arr[j]) {
                        flag = false;
                        break;
                    }
                }

                if(flag) {
                    new_arr[new_arr.length] = arr[i];
                }
            }

            console.log(new_arr);
        </script>
    </body>
</html>